﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProcessManagerPlugin.Common;
using System.Net.Sockets;

namespace ProcessManagerPlugin.Server
{
    public partial class ProcessListWnd : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public ProcessListWnd()
        {
            InitializeComponent();
        }

        private delegate void Del_RefreshList(IList<ProcessInfoObj> lst);
        public void RefreshList(IList<ProcessInfoObj> lst)
        {
            if(this.listBox1.InvokeRequired)
            {
                Del_RefreshList del = new Del_RefreshList(RefreshList);
                this.listBox1.BeginInvoke(del,lst);
            }
            else
            {
                this.listBox1.Items.Clear();
                foreach(ProcessInfoObj obj in lst)
                {
                    this.listBox1.Items.Add(obj.ProcessName);
                }
            }
        }

        private void ProcessListWnd_Load(object sender, EventArgs e)
        {

        }

        private void toolsRefreshProLst_Click(object sender, EventArgs e)
        {
            PluginObjects.ProcessManagerPlugin.GetClientProcessList();
        }
    }
}
